<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<title></title>
	<script type="text/javascript" src="js/d3.min.js"></script>
	<script type="text/javascript" src="js/strucMap.min.js"></script>
	<link rel="stylesheet" href="css/strucMap.min.css" />
<style>
	html, body {
		margin: 0;
		padding: 0;
	}
</style>
</head>

<body>
	<div id="topomap" style="margin: 0 auto;"></div>
	<script type="text/javascript">

		var nodePX = 0;
		var nodePY = 0;

		var options = {
			selector: "#topomap",
			width: document.body.clientWidth,//实际展开图宽度
			height: document.body.clientHeight,//实际展开图高度
			lineLength: 100,
//	        textColor:"#000",
//	        textFontFamily:'',
			nodesClick: function (t) {
				//if(t.index==0) t.fixed=1;//判断如果是第一级，移动后就将它固定
				t.fixed = 1;
				console.log(t);
				var nodeX = JSON.parse(JSON.stringify(t.x));
				var nodeY = JSON.parse(JSON.stringify(t.y));
				//xy都没有变，说明没有拖动
				if ((nodeX == nodePX) && (nodeY == nodePY)) {
					console.info("跳页面啦~~~~~~");
				}
			},
			nodesDragstart: function (t) {
				nodePX = JSON.parse(JSON.stringify(t.x));
				nodePY = JSON.parse(JSON.stringify(t.y));
				//console.log("移动开始",JSON.parse(JSON.stringify(t.x)),JSON.parse(JSON.stringify(t.y)));
			}
		};

		var nodesJson = [
		{ "fixed": true, "id": 0, "index": 0, "prop": { "name": "住院时间", "size": 32, "nTxt": "9天" }, "x": document.body.clientWidth/2, "y": document.body.clientHeight/2 },

		{ "id": 1, "index": 1, "prop": { "name": "基本信息", "size": 25 } },
		{ "id": 2, "index": 1, "prop": { "name": "生命体征", "size": 25 } },
		{ "id": 3, "index": 1, "prop": { "name": "呼吸参数", "size": 25 } },
		{ "id": 4, "index": 1, "prop": { "name": "检验", "size": 25 } },

		{ "id": 50, "index": 2, "prop": { "name": "年龄", "size": 15, "nTxt": "66岁" } },
		{ "id": 5, "index": 2, "prop": { "name": "体重", "size": 15, "nTxt": "80" } },
		{ "id": 6, "index": 2, "prop": { "name": "身高", "size": 15, "nTxt": "170" } },
		{ "id": 7, "index": 2, "prop": { "name": "性别", "size": 15, "nTxt": "男" } },

		{ "id": 8, "index": 2, "prop": { "name": "血压", "size": 15, "nTxt": "147/60" } },
		{ "id": 9, "index": 2, "prop": { "name": "平均血压", "size": 15, "nTxt": "100" } },
		{ "id": 10, "index": 2, "prop": { "name": "呼吸频率", "size": 15, "nTxt": "24" } },
		{ "id": 11, "index": 2, "prop": { "name": "心率", "size": 15, "nTxt": "83" } },
		{ "id": 12, "index": 2, "prop": { "name": "血氧饱和度", "size": 15, "nTxt": "100" } },
		{ "id": 13, "index": 2, "prop": { "name": "体温", "size": 15, "nTxt": "37.45" } },

		{ "id": 14, "index": 2, "prop": { "name": "潮气量", "size": 15, "nTxt": "500" } },
		{ "id": 15, "index": 2, "prop": { "name": "流量", "size": 15, "nTxt": "5" } },
		{ "id": 16, "index": 2, "prop": { "name": "气道峰压", "size": 15, "nTxt": "22" } },
		{ "id": 17, "index": 2, "prop": { "name": "呼气末正压", "size": 15, "nTxt": "5" } },
		{ "id": 18, "index": 2, "prop": { "name": "FiO2", "size": 15, "nTxt": "40" } },

		{ "id": 19, "index": 2, "prop": { "name": "CRP", "size": 15, "nTxt": "6.445" } },
		{ "id": 20, "index": 2, "prop": { "name": "阴离子间隙", "size": 15, "nTxt": "14.24990215" } },
		{ "id": 21, "index": 2, "prop": { "name": "白蛋白", "size": 15, "nTxt": "39.6" } },
		{ "id": 22, "index": 2, "prop": { "name": "中性粒细胞", "size": 15, "nTxt": "0.941" } },
		{ "id": 23, "index": 2, "prop": { "name": "碳酸氢根", "size": 15, "nTxt": "28.6" } },
		{ "id": 24, "index": 2, "prop": { "name": "胆红素", "size": 15, "nTxt": "17.7" } },

		{ "id": 25, "index": 2, "prop": { "name": "肌酐", "size": 15, "nTxt": "80.3" } },
		{ "id": 26, "index": 2, "prop": { "name": "氯", "size": 15, "nTxt": "113.7" } },
		{ "id": 27, "index": 2, "prop": { "name": "血糖", "size": 15, "nTxt": "6.75" } },
		{ "id": 28, "index": 2, "prop": { "name": "血球容积", "size": 15, "nTxt": "0.416" } },
		{ "id": 29, "index": 2, "prop": { "name": "血红蛋白", "size": 15, "nTxt": "150" } },
		{ "id": 30, "index": 2, "prop": { "name": "血小板", "size": 15, "nTxt": "119" } },
		{ "id": 31, "index": 2, "prop": { "name": "钾", "size": 15, "nTxt": "3.9" } },
		{ "id": 32, "index": 2, "prop": { "name": "PTT", "size": 15, "nTxt": "51.6" } },
		{ "id": 33, "index": 2, "prop": { "name": "INR", "size": 15, "nTxt": "1.21" } },
		{ "id": 34, "index": 2, "prop": { "name": "PT", "size": 15, "nTxt": "15.1" } },
		{ "id": 35, "index": 2, "prop": { "name": "钠", "size": 15, "nTxt": "148.9" } },
		{ "id": 36, "index": 2, "prop": { "name": "血尿素氮", "size": 15, "nTxt": "5.17" } },

		{ "id": 37, "index": 2, "prop": { "name": "白细胞计数", "size": 15, "nTxt": "9.49" } },
		{ "id": 38, "index": 2, "prop": { "name": "肌酸激酶", "size": 15, "nTxt": "243.8" } },
		{ "id": 39, "index": 2, "prop": { "name": "肌酸激酶同工酶", "size": 15, "nTxt": "2.65" } },
		{ "id": 40, "index": 2, "prop": { "name": "D-二聚体", "size": 15, "nTxt": "2.32" } },
		{ "id": 41, "index": 2, "prop": { "name": "NT-proBNP", "size": 15, "nTxt": "136" } },

		{ "id": 42, "index": 2, "prop": { "name": "血浆纤维蛋白原", "size": 15, "nTxt": "3.71" } },
		{ "id": 43, "index": 2, "prop": { "name": "血清乳酸脱氢酶", "size": 15, "nTxt": "204.5" } },
		{ "id": 44, "index": 2, "prop": { "name": "镁", "size": 15, "nTxt": "0.81" } },
		{ "id": 45, "index": 2, "prop": { "name": "动脉血氧分压", "size": 15, "nTxt": "71.3" } },
		{ "id": 46, "index": 2, "prop": { "name": "动脉血二氧化碳分压", "size": 15, "nTxt": "42.6" } },
		{ "id": 47, "index": 2, "prop": { "name": "动脉血氧饱和度", "size": 15, "nTxt": "95" } },

		{ "id": 48, "index": 2, "prop": { "name": "troponin_t", "size": 15, "nTxt": "0.009" } },
		{ "id": 49, "index": 2, "prop": { "name": "腹水白细胞", "size": 15, "nTxt": "11.7" } }

		];
		//source和target都是按照数组的顺序来的，下标
		var linksJson = [
			{ "source": 0, "target": 1, },
			{ "source": 0, "target": 2, },
			{ "source": 0, "target": 3, },
			{ "source": 0, "target": 4, },

			{ "source": 1, "target": 50, },
			{ "source": 1, "target": 5, },
			{ "source": 1, "target": 6, },
			{ "source": 1, "target": 7, },

			{ "source": 2, "target": 8, },
			{ "source": 2, "target": 9, },
			{ "source": 2, "target": 10, },
			{ "source": 2, "target": 11, },
			{ "source": 2, "target": 12, },
			{ "source": 2, "target": 13, },

			{ "source": 3, "target": 14, },
			{ "source": 3, "target": 15, },
			{ "source": 3, "target": 16, },
			{ "source": 3, "target": 17, },
			{ "source": 3, "target": 18, },

			{ "source": 4, "target": 19, },
			{ "source": 4, "target": 20, },
			{ "source": 4, "target": 21, },
			{ "source": 4, "target": 22, },
			{ "source": 4, "target": 23, },
			{ "source": 4, "target": 24, },
			{ "source": 4, "target": 25, },
			{ "source": 4, "target": 26, },
			{ "source": 4, "target": 27, },
			{ "source": 4, "target": 28, },
			{ "source": 4, "target": 29, },
			{ "source": 4, "target": 30, },
			{ "source": 4, "target": 31, },
			{ "source": 4, "target": 32, },
			{ "source": 4, "target": 33, },
			{ "source": 4, "target": 34, },
			{ "source": 4, "target": 35, },
			{ "source": 4, "target": 36, },
			{ "source": 4, "target": 37, },
			{ "source": 4, "target": 38, },
			{ "source": 4, "target": 39, },
			{ "source": 4, "target": 40, },
			{ "source": 4, "target": 41, },
			{ "source": 4, "target": 42, },
			{ "source": 4, "target": 43, },
			{ "source": 4, "target": 44, },
			{ "source": 4, "target": 45, },
			{ "source": 4, "target": 46, },
			{ "source": 4, "target": 47, },
			{ "source": 4, "target": 48, },
			{ "source": 4, "target": 49, }
		];

		console.log("初始化打印", linksJson);
		loadMap(options, nodesJson, linksJson);
	</script>
</body>

</html>